package current.security.dao.impl;

import java.util.List;
import org.springframework.stereotype.Repository;
import current.security.dao.ISecurityDao;
import current.security.dao.support.BaseHibernateDaoSupport;
import current.security.user.domain.Resc;
import current.security.user.domain.User;


@Repository("securityDao")
public class SecurityDao extends BaseHibernateDaoSupport implements ISecurityDao  {

	@Override
	public List<Resc> loadRescByType(String type) {
		String hql = "from Resc where type = :type";
		getHibernateTemplate().find(hql, type);
		return null;
	}

	@Override
	public List<Resc> queryAll() {
		// TODO Auto-generated method stub
		List<Resc> listResc = getHibernateTemplate().loadAll(Resc.class);
		return listResc;
	}

	@Override
	public User queryUserByName(String username) {
		String hql = "from User where name = ?";
		List<?> listUser = getHibernateTemplate().find(hql, username);
		if(listUser != null && listUser.size() > 0){
			return (User)listUser.get(0);
		}
		return null;
	}

}
